<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui" xmlns:adm="http://github.com/adminfaces"
                template="#{layoutMB.template}">
    <f:loadBundle var="msg" basename="admin"/>
    <ui:define name="title">
        #{msg['car.form']}
    </ui:define>

    <ui:define name="body">

        <adm:breadcrumb title="#{empty carFormController.id ? 'New Car' : 'Car:'.concat(carFormController.car.name)}"
                        link="car-form.xhtml?id=#{carFormController.id}"/>

        <h:form id="form" prependId="false">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div id="main-buttons" class="hidden-sm hidden-xs">
                        <p:commandButton value="#{msg['button.save']}" action="#{carFormController.save}" update="@form"
                                         icon="fa fa-check" styleClass="btn-primary"/>
                        <p:spacer width="5"/>
                        <p:commandButton value="#{msg['button.clear']}" action="#{carFormController.clear}"
                                         icon="fa fa-refresh" styleClass="btn-success"
                                         update="@form" rendered="#{carFormController.isNew()}" resetValues="true"/>
                        <p:commandButton value="#{msg['button.delete']}" action="#{carFormController.delete}"
                                         rendered="#{not carFormController.isNew()}" icon="fa fa-trash"
                                         styleClass="btn-danger">
                            <p:confirm header="Confirmation" message="#{msg['dialog.delete.confirm']}"
                                       icon="ui-icon-danger"/>
                        </p:commandButton>
                        <p:spacer width="5"/>
                        <p:commandButton value="#{msg['button.back']}" immediate="true"
                                         action="/car/car-list?faces-redirect=true"
                                         icon="fa fa-reply"/>
                    </div>
                    <p:splitButton value="#{msg['button.save']}" action="#{carFormController.save}" update="@form"
                                   icon="fa fa-check" styleClass="hidden-md hidden-lg btn-primary">
                        <p:menuitem value="#{msg['button.clear']}" action="#{carFormController.clear}" update="@form"
                                    rendered="#{carFormController.isNew()}" resetValues="true" icon="fa fa-refresh"/>
                        <p:menuitem value="#{msg['button.delete']}" action="#{carFormController.delete}"
                                    rendered="#{not carFormController.isNew()}" icon="fa fa-trash">
                            <p:confirm header="Confirmation" message="#{msg['dialog.delete.confirm']}"
                                       icon="ui-icon-danger"/>
                        </p:menuitem>
                        <p:separator/>
                        <p:menuitem value="#{msg['button.back']}" action="/car/car-list?faces-redirect=true"
                                    immediate="true" icon="fa fa-reply"/>
                    </p:splitButton>

                    <p:separator/>

                    <div class="ui-g ui-fluid">
                        <div class="ui-sm-12 ui-md-2 ui-lg-1">
                            <p:outputLabel for="id" value="ID"/>
                        </div>
                        <div class="ui-sm-12 ui-md-4 ui-lg-5">
                            <p:inputText id="id" value="#{carFormController.car.id}" size="4"
                                         readonly="true" styleClass="form-control" style="width: 100%"/>
                        </div>
                        <div class="ui-sm-12 ui-md-2 ui-lg-1">
                            <p:outputLabel value="Model" for="inptModel"/>
                        </div>
                        <div class="ui-sm-12 ui-md-4 ui-lg-5">
                            <p:inputText id="inptModel" value="#{carFormController.car.model}"/>
                        </div>
                        <div class="ui-sm-12 ui-md-2 ui-lg-1">
                            <p:outputLabel value="Name" for="inptName"/>
                        </div>
                        <div class="ui-sm-12 ui-md-4 ui-lg-5">
                            <p:inputText id="inptName" value="#{carFormController.car.name}"/>
                        </div>
                        <div class="ui-sm-12 ui-md-2 ui-lg-1">
                            <p:outputLabel value="Price" for="inptPrice"/>
                        </div>
                        <div class="ui-sm-12 ui-md-4 ui-lg-5">
                            <p:inputNumber id="inptPrice" value="#{carFormController.car.price}"/>
                        </div>
                    </div>
                </div>
            </div>

            <ui:include src="/includes/confirm-dialog.xhtml"/>

        </h:form>

    </ui:define>

</ui:composition>
